package com.itheima.d7_tcp4.ZengTest;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName server
 * @Author 16799
 * @Date 2025/9/26 20:56
 * @Version 1.0
 * @Description TODO
 **/
public class server {
    public static List<Socket> onLineSockets = new ArrayList<>();
    public static void main(String[] args) throws Exception {
        System.out.println("---------------服务端启动-------------");
        ServerSocket serverSocket = new ServerSocket(8877);

        while (true){
            Socket socket = serverSocket.accept();
            onLineSockets.add(socket);
            System.out.println("有客户端已上线： " + socket.getRemoteSocketAddress());
            new serverThread(socket).start();
        }


    }
}
